package com.chat;

import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/**
 * mybatis plus代码生成
 */
public class FastAutoGenerator {
    public static void main(String[] args) {
        com.baomidou.mybatisplus.generator.FastAutoGenerator.create("jdbc:mysql://47.120.47.112:3306/chat_db?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true", "root", "iwkmvje8349ucjkd0")
                .globalConfig(builder -> {
                    builder.author("weikjie") // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("mybatis-plus"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.chat") // 设置父包名
//                                    .moduleName("chat-service") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "mybatis-plus"));// 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.enableCapitalMode();
                    builder.entityBuilder()
                            .enableChainModel()//开启链式模型
                            .enableLombok();
                    builder.addInclude("t_user") // 设置需要生成的表名
//                                    .addInclude("t_role")
//                                    .addInclude("t_admin")
//                                    .addInclude("t_authority")
//                                    .addInclude("t_role_authority_mapping")
//                                    .addInclude("t_history_message")
//                                    .addInclude("t_group")
//                                    .addInclude("t_group_user_mapping")
//                                    .addInclude("t_message_channel_mapping")
//                                    .addInclude("t_apply")
                                    //.addInclude("t_routeInfo")
                                    //.addInclude("t_route_role")
                                    //.addInclude("t_disable_account")
//                                    .addInclude("t_disable_group")
                                    .addInclude("t_version")
                                    .addInclude("t_file_map")
//                                    .addInclude("t_user_appeal")
//                                    .addInclude("t_user_feedback")
                                    .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                        })
                        .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                        .execute();
    }
}
